Getting value null when click on GoogleMap.setOnMarkerClickListener in Android
enter image description hereI am working on a map application where I am adding marker through latitude and longitude coming from JSON. Also other information are coming with each latitude and longitude. I have store this info into an array list. Marker is showing exact location but problem arises when I am trying to show this info into an custom dialog in Google marker click in respect of marker position, value is showing null. How to solve this problem?
My MarkerHolder class
public class MarkerHolder {
public String bunch_jobName;
public String addess;
public String destiny;
public String note;
public MarkerHolder(String bunch_jobName, String addess, String destiny, String note) {
bunch_jobName = bunch_jobName;
addess = addess;
destiny = destiny;
note = note;
}
}
GoogleMap.setOnMarkerClickListener(new com.google.android.gms.maps.GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker){
cal = new Dialog(activity);
cal.setCanceledOnTouchOutside(true);
cal.requestWindowFeature(Window.FEATURE_NO_TITLE);
cal.getWindow().setBackgroundDrawable(new ColorDrawable(0));
cal.setContentView(R.layout.marker_popup_info);
cal.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
TextView stops_name = cal.findViewById(R.id.tv_stops_name);
TextView stops_addr = cal.findViewById(R.id.tv_stops_address);
TextView stops_destination = cal.findViewById(R.id.tv_destiny);
TextView stops_note = cal.findViewById(R.id.tv_note);
MarkerHolder mHolder = markerHolderMap.get(marker.getId());
stops_name.setText(mHolder.bunch_jobName);
stops_addr.setText(mHolder.bunch_jobName);
stops_destination.setText(mHolder.bunch_jobName);
stops_note.setText(mHolder.bunch_jobName);
cal.show();
return false;
}
});
With in JSON
MarkerOptions options = new MarkerOptions();
options.position(new LatLng(location_lat1, location_longi1));
Marker marker = GoogleMap.addMarker(options);
MarkerHolder mHolder = new MarkerHolder(task_job_name,job_merchant,contact_no,task_address);
markerHolderMap.put(marker.getId(), mHolder);
android
add a comment |
enter image description hereI am working on a map application where I am adding marker through latitude and longitude coming from JSON. Also other information are coming with each latitude and longitude. I have store this info into an array list. Marker is showing exact location but problem arises when I am trying to show this info into an custom dialog in Google marker click in respect of marker position, value is showing null. How to solve this problem?
My MarkerHolder class
public class MarkerHolder {
public String bunch_jobName;
public String addess;
public String destiny;
public String note;
public MarkerHolder(String bunch_jobName, String addess, String destiny, String note) {
bunch_jobName = bunch_jobName;
addess = addess;
destiny = destiny;
note = note;
}
}
GoogleMap.setOnMarkerClickListener(new com.google.android.gms.maps.GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker){
cal = new Dialog(activity);
cal.setCanceledOnTouchOutside(true);
cal.requestWindowFeature(Window.FEATURE_NO_TITLE);
cal.getWindow().setBackgroundDrawable(new ColorDrawable(0));
cal.setContentView(R.layout.marker_popup_info);
cal.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
TextView stops_name = cal.findViewById(R.id.tv_stops_name);
TextView stops_addr = cal.findViewById(R.id.tv_stops_address);
TextView stops_destination = cal.findViewById(R.id.tv_destiny);
TextView stops_note = cal.findViewById(R.id.tv_note);
MarkerHolder mHolder = markerHolderMap.get(marker.getId());
stops_name.setText(mHolder.bunch_jobName);
stops_addr.setText(mHolder.bunch_jobName);
stops_destination.setText(mHolder.bunch_jobName);
stops_note.setText(mHolder.bunch_jobName);
cal.show();
return false;
}
});
With in JSON
MarkerOptions options = new MarkerOptions();
options.position(new LatLng(location_lat1, location_longi1));
Marker marker = GoogleMap.addMarker(options);
MarkerHolder mHolder = new MarkerHolder(task_job_name,job_merchant,contact_no,task_address);
markerHolderMap.put(marker.getId(), mHolder);
android
post your crash related logcat and also use debugger to see where the app is crashing.
– beginner
Nov 16 '18 at 9:50
Actually there are not happened any crash issue.When I am print System.out.println("Value"+mHolder.bunch_jobName) in marker click it returns blank.Please find my attached screen shot.
– Mangaldip D
Nov 16 '18 at 11:19
It is not clear in your code where markerHolderMap is initialized. I will say again, use debugger to check what value your markerHolderMap is holding when you click your marker.
– beginner
Nov 16 '18 at 12:03
static HashMap<String, MarkerHolder> markerHolderMap = new HashMap<String, MarkerHolder>(); this is markerHolderMap initializetion
– Mangaldip D
Nov 16 '18 at 12:41
you should check 'why' your map is empty when you click on your marker, does the hashmap has any value? So thats why i am saying that you should use debugger, or post your whole code so that we can see what we doing incorrectly.
– beginner
Nov 16 '18 at 13:01
add a comment |
enter image description hereI am working on a map application where I am adding marker through latitude and longitude coming from JSON. Also other information are coming with each latitude and longitude. I have store this info into an array list. Marker is showing exact location but problem arises when I am trying to show this info into an custom dialog in Google marker click in respect of marker position, value is showing null. How to solve this problem?
My MarkerHolder class
public class MarkerHolder {
public String bunch_jobName;
public String addess;
public String destiny;
public String note;
public MarkerHolder(String bunch_jobName, String addess, String destiny, String note) {
bunch_jobName = bunch_jobName;
addess = addess;
destiny = destiny;
note = note;
}
}
GoogleMap.setOnMarkerClickListener(new com.google.android.gms.maps.GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker){
cal = new Dialog(activity);
cal.setCanceledOnTouchOutside(true);
cal.requestWindowFeature(Window.FEATURE_NO_TITLE);
cal.getWindow().setBackgroundDrawable(new ColorDrawable(0));
cal.setContentView(R.layout.marker_popup_info);
cal.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
TextView stops_name = cal.findViewById(R.id.tv_stops_name);
TextView stops_addr = cal.findViewById(R.id.tv_stops_address);
TextView stops_destination = cal.findViewById(R.id.tv_destiny);
TextView stops_note = cal.findViewById(R.id.tv_note);
MarkerHolder mHolder = markerHolderMap.get(marker.getId());
stops_name.setText(mHolder.bunch_jobName);
stops_addr.setText(mHolder.bunch_jobName);
stops_destination.setText(mHolder.bunch_jobName);
stops_note.setText(mHolder.bunch_jobName);
cal.show();
return false;
}
});
With in JSON
MarkerOptions options = new MarkerOptions();
options.position(new LatLng(location_lat1, location_longi1));
Marker marker = GoogleMap.addMarker(options);
MarkerHolder mHolder = new MarkerHolder(task_job_name,job_merchant,contact_no,task_address);
markerHolderMap.put(marker.getId(), mHolder);
android
enter image description hereI am working on a map application where I am adding marker through latitude and longitude coming from JSON. Also other information are coming with each latitude and longitude. I have store this info into an array list. Marker is showing exact location but problem arises when I am trying to show this info into an custom dialog in Google marker click in respect of marker position, value is showing null. How to solve this problem?
My MarkerHolder class
public class MarkerHolder {
public String bunch_jobName;
public String addess;
public String destiny;
public String note;
public MarkerHolder(String bunch_jobName, String addess, String destiny, String note) {
bunch_jobName = bunch_jobName;
addess = addess;
destiny = destiny;
note = note;
}
}
GoogleMap.setOnMarkerClickListener(new com.google.android.gms.maps.GoogleMap.OnMarkerClickListener() {
@Override
public boolean onMarkerClick(Marker marker){
cal = new Dialog(activity);
cal.setCanceledOnTouchOutside(true);
cal.requestWindowFeature(Window.FEATURE_NO_TITLE);
cal.getWindow().setBackgroundDrawable(new ColorDrawable(0));
cal.setContentView(R.layout.marker_popup_info);
cal.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
TextView stops_name = cal.findViewById(R.id.tv_stops_name);
TextView stops_addr = cal.findViewById(R.id.tv_stops_address);
TextView stops_destination = cal.findViewById(R.id.tv_destiny);
TextView stops_note = cal.findViewById(R.id.tv_note);
MarkerHolder mHolder = markerHolderMap.get(marker.getId());
stops_name.setText(mHolder.bunch_jobName);
stops_addr.setText(mHolder.bunch_jobName);
stops_destination.setText(mHolder.bunch_jobName);
stops_note.setText(mHolder.bunch_jobName);
cal.show();
return false;
}
});
With in JSON
MarkerOptions options = new MarkerOptions();
options.position(new LatLng(location_lat1, location_longi1));
Marker marker = GoogleMap.addMarker(options);
MarkerHolder mHolder = new MarkerHolder(task_job_name,job_merchant,contact_no,task_address);
markerHolderMap.put(marker.getId(), mHolder);
android
android
edited Nov 16 '18 at 12:46
Mangaldip D
asked Nov 16 '18 at 8:24
Mangaldip DMangaldip D
64
64
post your crash related logcat and also use debugger to see where the app is crashing.
– beginner
Nov 16 '18 at 9:50
Actually there are not happened any crash issue.When I am print System.out.println("Value"+mHolder.bunch_jobName) in marker click it returns blank.Please find my attached screen shot.
– Mangaldip D
Nov 16 '18 at 11:19
It is not clear in your code where markerHolderMap is initialized. I will say again, use debugger to check what value your markerHolderMap is holding when you click your marker.
– beginner
Nov 16 '18 at 12:03
static HashMap<String, MarkerHolder> markerHolderMap = new HashMap<String, MarkerHolder>(); this is markerHolderMap initializetion
– Mangaldip D
Nov 16 '18 at 12:41
you should check 'why' your map is empty when you click on your marker, does the hashmap has any value? So thats why i am saying that you should use debugger, or post your whole code so that we can see what we doing incorrectly.
– beginner
Nov 16 '18 at 13:01
add a comment |
post your crash related logcat and also use debugger to see where the app is crashing.
– beginner
Nov 16 '18 at 9:50
Actually there are not happened any crash issue.When I am print System.out.println("Value"+mHolder.bunch_jobName) in marker click it returns blank.Please find my attached screen shot.
– Mangaldip D
Nov 16 '18 at 11:19
It is not clear in your code where markerHolderMap is initialized. I will say again, use debugger to check what value your markerHolderMap is holding when you click your marker.
– beginner
Nov 16 '18 at 12:03
static HashMap<String, MarkerHolder> markerHolderMap = new HashMap<String, MarkerHolder>(); this is markerHolderMap initializetion
– Mangaldip D
Nov 16 '18 at 12:41
you should check 'why' your map is empty when you click on your marker, does the hashmap has any value? So thats why i am saying that you should use debugger, or post your whole code so that we can see what we doing incorrectly.
– beginner
Nov 16 '18 at 13:01
post your crash related logcat and also use debugger to see where the app is crashing.
– beginner
Nov 16 '18 at 9:50
post your crash related logcat and also use debugger to see where the app is crashing.
– beginner
Nov 16 '18 at 9:50
Actually there are not happened any crash issue.When I am print System.out.println("Value"+mHolder.bunch_jobName) in marker click it returns blank.Please find my attached screen shot.
– Mangaldip D
Nov 16 '18 at 11:19
Actually there are not happened any crash issue.When I am print System.out.println("Value"+mHolder.bunch_jobName) in marker click it returns blank.Please find my attached screen shot.
– Mangaldip D
Nov 16 '18 at 11:19
It is not clear in your code where markerHolderMap is initialized. I will say again, use debugger to check what value your markerHolderMap is holding when you click your marker.
– beginner
Nov 16 '18 at 12:03
It is not clear in your code where markerHolderMap is initialized. I will say again, use debugger to check what value your markerHolderMap is holding when you click your marker.
– beginner
Nov 16 '18 at 12:03
static HashMap<String, MarkerHolder> markerHolderMap = new HashMap<String, MarkerHolder>(); this is markerHolderMap initializetion
– Mangaldip D
Nov 16 '18 at 12:41
static HashMap<String, MarkerHolder> markerHolderMap = new HashMap<String, MarkerHolder>(); this is markerHolderMap initializetion
– Mangaldip D
Nov 16 '18 at 12:41
you should check 'why' your map is empty when you click on your marker, does the hashmap has any value? So thats why i am saying that you should use debugger, or post your whole code so that we can see what we doing incorrectly.
– beginner
Nov 16 '18 at 13:01
you should check 'why' your map is empty when you click on your marker, does the hashmap has any value? So thats why i am saying that you should use debugger, or post your whole code so that we can see what we doing incorrectly.
– beginner
Nov 16 '18 at 13:01
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333966%2fgetting-value-null-when-click-on-googlemap-setonmarkerclicklistener-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53333966%2fgetting-value-null-when-click-on-googlemap-setonmarkerclicklistener-in-android%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
post your crash related logcat and also use debugger to see where the app is crashing.
– beginner
Nov 16 '18 at 9:50
Actually there are not happened any crash issue.When I am print System.out.println("Value"+mHolder.bunch_jobName) in marker click it returns blank.Please find my attached screen shot.
– Mangaldip D
Nov 16 '18 at 11:19
It is not clear in your code where markerHolderMap is initialized. I will say again, use debugger to check what value your markerHolderMap is holding when you click your marker.
– beginner
Nov 16 '18 at 12:03
static HashMap<String, MarkerHolder> markerHolderMap = new HashMap<String, MarkerHolder>(); this is markerHolderMap initializetion
– Mangaldip D
Nov 16 '18 at 12:41
you should check 'why' your map is empty when you click on your marker, does the hashmap has any value? So thats why i am saying that you should use debugger, or post your whole code so that we can see what we doing incorrectly.
– beginner
Nov 16 '18 at 13:01