I've downloaded this package and got it working - love it!
I'm struggling with one aspect though - how can I display the map with multiple markers and infowindows?
I've set this up so that there is a "Map" node and a series of "Map Marker" child nodes - so a map may have zero or many markers.
I can get multiple markers to display, but they all take the info window of the last one in the foreach loop that I'm using in the code.
Any suggestions for how best to set that up?
I've had this working in XSLT files in v4.11.10, but am now trying to replicate this in a Razor Partial View Macro in v7.2 and can't see how to do it, being a newbie when it comes to Razor!
Also, I'd like to add the map to a Grid Text Page similar to the one on the Fanoe starter kit. Is it best to add this as a macro, or is there a way to set up a map editor directly within the grid?
<script> function initialize() { var myLatlng = new google.maps.LatLng(@latitude, @longitude); var mapOptions = { zoom: @zoom, center: myLatlng }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
@foreach (var item in markers) { string markerLocation = @item.mapLocation.ToString().Trim(); string[] markerLocationInfo = @markerLocation.Split( ',' ); <text> var markerLatitude = @markerLocationInfo[0]; var markerLongitude = @markerLocationInfo[1]; var contentString = '@item.markerInfo'; var markerName = '@item.pageName';
var infowindow = new google.maps.InfoWindow({ content: contentString, maxWidth: 200 }); var markerLatlng = new google.maps.LatLng(markerLatitude, markerLongitude); var marker = new google.maps.Marker({ position: markerLatlng, map: map, title: markerName });
Not too sure why you have added a question to a 2 year old thread, but this package, Angular Google Maps, has been deprecated for Terratype which has superior features and also contains examples in the manual showing exactly how to do this. It comes with its own renderer which takes all the hassle out of displaying maps
But, if you are intent on continuing to use Angular Google Maps, then like any data type you can place multiple copies of it either across various content nodes or within complex datatypes like Grid Editor, Nested Content or Archetype. Once you have multiple maps, you then have to write your own javascript code to display those multiple maps as one map. The code listed above by Allan does do that except for a small issue to do with closure, which can be rectified using the 'with' command
with ({
c : contentString
}) {
var infowindow = new google.maps.InfoWindow({
content: contentString,
maxWidth: 200
});
}
Multiple markers on Google Map
I've downloaded this package and got it working - love it!
I'm struggling with one aspect though - how can I display the map with multiple markers and infowindows?
I've set this up so that there is a "Map" node and a series of "Map Marker" child nodes - so a map may have zero or many markers.
I can get multiple markers to display, but they all take the info window of the last one in the foreach loop that I'm using in the code.
Any suggestions for how best to set that up?
I've had this working in XSLT files in v4.11.10, but am now trying to replicate this in a Razor Partial View Macro in v7.2 and can't see how to do it, being a newbie when it comes to Razor!
Also, I'd like to add the map to a Grid Text Page similar to the one on the Fanoe starter kit. Is it best to add this as a macro, or is there a way to set up a map editor directly within the grid?
Thanks
Allan
Hi Allan,
Show your map code please. Are you using Google Map API ?
Hi Alex
Here's the code as it currently stands:
Thanks
Allan
Looks to me you have a closure problem with your addListerner(), which will use the last value of infowindow.
http://stackoverflow.com/questions/7044587/adding-multiple-markers-with-infowindows-google-maps-api
Hi Jonathan
Thank you for that - got it sorted now using that help.
Allan
Can you please provide the full description on how you added multiple marker on Maps using this package Angular Google Maps?
Hi Abhishek,
Not too sure why you have added a question to a 2 year old thread, but this package, Angular Google Maps, has been deprecated for Terratype which has superior features and also contains examples in the manual showing exactly how to do this. It comes with its own renderer which takes all the hassle out of displaying maps
But, if you are intent on continuing to use Angular Google Maps, then like any data type you can place multiple copies of it either across various content nodes or within complex datatypes like Grid Editor, Nested Content or Archetype. Once you have multiple maps, you then have to write your own javascript code to display those multiple maps as one map. The code listed above by Allan does do that except for a small issue to do with closure, which can be rectified using the 'with' command
Cheers
Jonathan
is working on a reply...