Google Map API Infobox and for Loop - google-maps

hoping to get some help here. I have locations on a database that I have successfully managed to put into an array that successfully plots the markers on the map. The only drawback is i want to customise the look of the market infowindow, so im using infobox.
But when I echo the variable from my array it echo's the last result into each infobox and im completly stumped on this one.
Could someone please look at my code and see where iv gone wrong or point me in the right direction?
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox.js"></script>
<script type="text/javascript" language="javascript">
// -- Location API -- //
infos = [];
function initialize() {
var myOptions = {
zoom: 3,
center: new google.maps.LatLng(54.57206165565852, 12.48046875),
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
/* now inside your initialise function */
infowindow = new google.maps.InfoWindow({
content: "holding..."
});
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, beaches);
}
/**
* Data for the markers consisting of a name, a LatLng and a zIndex for
* the order in which these markers should display on top of each
* other.
*/
var beaches = [
[1, 'Peterhead', 57.487044, -1.800417, 1, 'Building 1', 'Glenbank'],
[2, 'Cowdenbeath', 56.09946, -3.35909, 1, 'Building 22', 'The Paragon Works Station'],
[3, 'Norfolk', 52.595971, 1.728609, 1, 'Building 3', '39 Southgates Road']
];
function setMarkers(map, locations) {
// Add markers to the map
// Marker sizes are expressed as a Size of X,Y
// where the origin of the image (0,0) is located
// in the top left of the image.
// Origins, anchor positions and coordinates of the marker
// increase in the X direction to the right and in
// the Y direction down.
var image = new google.maps.MarkerImage('http://stlab.co.uk/group/assets/img/icons/map-pin.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(15, 22),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(5, 22));
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var html = '<div class="phoney">'+beach[4]+'<br>'+beach[5]+'</div>'
var myLatLng = new google.maps.LatLng(beach[2], beach[3]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
content:html,
title: beach[1],
zIndex: beach[4]
});
var boxText = document.createElement("div");
boxText.style.cssText = "border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px;";
boxText.innerHTML = beach[0]+"<br>"+beach[6];
var myOptions = {
content: boxText,
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-140, 0),
zIndex: null,
boxStyle: {
background: "url('tipbox.gif') no-repeat",
opacity: 0.75,
width: "280px"
},
closeBoxMargin: "10px 2px 2px 2px",
closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
infoBoxClearance: new google.maps.Size(1, 1),
isHidden: false,
pane: "floatPane",
enableEventPropagation: false
};
google.maps.event.addListener(marker, "click", function (e) {
ib.open(map, this);
});
var ib = new InfoBox(myOptions);
}
}
</script>

here is the working example.
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/tags/infobox/1.1.9/src/infobox.js"></script>
<script type="text/javascript">
// -- Location API -- //
var infos = [];
var ib = new InfoBox();
function initialize() {
var myOptions = {
zoom: 3,
center: new google.maps.LatLng(54.57206165565852, 12.48046875),
mapTypeControl: false,
mapTypeId: google.maps.MapTypeId.TERRAIN
}
/* now inside your initialise function */
var infowindow = new google.maps.InfoWindow({
content: "holding..."
});
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
var beaches = [
[1, 'Peterhead', 57.487044, -1.800417, 1, 'Building 1', 'Glenbank'],
[2, 'Cowdenbeath', 56.09946, -3.35909, 1, 'Building 22', 'The Paragon Works Station'],
[3, 'Norfolk', 52.595971, 1.728609, 1, 'Building 3', '39 Southgates Road']
];
for (var i = 0; i < beaches.length; i++) {
setMarkers(map, beaches[i]);
}
}
/**
* Data for the markers consisting of a name, a LatLng and a zIndex for
* the order in which these markers should display on top of each
* other.
*/
function setMarkers(map, beach) {
// Add markers to the map
// Marker sizes are expressed as a Size of X,Y
// where the origin of the image (0,0) is located
// in the top left of the image.
// Origins, anchor positions and coordinates of the marker
// increase in the X direction to the right and in
// the Y direction down.
var image = new google.maps.MarkerImage('http://stlab.co.uk/group/assets/img/icons/map-pin.png',
// This marker is 20 pixels wide by 32 pixels tall.
new google.maps.Size(15, 22),
// The origin for this image is 0,0.
new google.maps.Point(0,0),
// The anchor for this image is the base of the flagpole at 0,32.
new google.maps.Point(5, 22));
//var beach = locations[i];
var html = '<div class="phoney">'+beach[4]+'<br>'+beach[5]+'</div>'
var myLatLng = new google.maps.LatLng(beach[2], beach[3]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
content:html,
title: beach[1],
zIndex: beach[4]
});
var boxText = document.createElement("div");
boxText.style.cssText = "border: 1px solid black; margin-top: 8px;background: yellow; padding: 5px;";
boxText.innerHTML = beach[0]+"<br>"+beach[6];
var myOptions = {
content:boxText,
disableAutoPan: false,
maxWidth: 0,
pixelOffset: new google.maps.Size(-140, 0),
zIndex: null,
boxStyle: {
background: "url('tipbox.gif') no-repeat",
opacity: 0.75,
width: "280px"
},
closeBoxMargin: "10px 2px 2px 2px",
closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
infoBoxClearance: new google.maps.Size(1, 1),
isHidden: false,
pane: "floatPane",
enableEventPropagation: false
};
google.maps.event.addListener(marker, "click", function (e) {
ib.setOptions(myOptions);
ib.open(map, marker);
});
}
</script>

Related

How to get the current radius after zoom in or zoom out

I've placed a marker(fillcolored with #333) at the center of the map that act as a radius. Initially the size of the marker was set to 151px.
Here's the scenario, if the user click the zoom out button, the size of the marker remain as is but the radius captured on the map is greater.
And if the user click the zoom in button, still the size of the marker remain the same but the radius been captured will become lesser.
The reason why I did this is I want to know if the person's current location(GPS) was inside on that specific radius that he specified using his mobile app.
My question is how can I get the current radius of the marker after the user zoom out or zoom in ? Any ideas about this problem? Thanks.
My Google Map API script:
function initGoogleMap() {
console.info('initGoogleMap');
var latitude = 10.314241194743438;
var longitude = 123.90536092883599;
var zoom = 17;
var latlng = new google.maps.LatLng(latitude, longitude);
var map_options = {
center: latlng,
zoom: zoom,
draggable: true,
zoomControl: true,
};
var map = new google.maps.Map(document.getElementById('map_canvas'), map_options);
var marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map,
icon: {
path: google.maps.SymbolPath.CIRCLE,
fillOpacity: 0.5,
fillColor: "#333",
strokeOpacity: 1.0,
strokeColor: '#CB0909',
strokeWeight: 0,
scale: 151 // in pixels
}
});
console.info('init zoom level: ', zoom);
marker.bindTo('position', map, 'center');
}
initGoogleMap();
See attached demo of the problem:
https://jsfiddle.net/sudogem/kkpt9t07/3/
If you know the radius of the circle in pixels you can compute the latitude and longitude of a point on the circumference using .fromLatLngToDivPixel and .fromDivPixelToLatLng, then use that to compute the radius of the circle in meters:
function computeRadius() {
if (!overlay) return;
var centerPixel = overlay.getProjection().fromLatLngToDivPixel(marker.getPosition());
var outerPoint = new google.maps.Point(centerPixel.x + 151, centerPixel.y);
var pixelLatLng = overlay.getProjection().fromDivPixelToLatLng(outerPoint);
if (!edgeMarker || !edgeMarker.setPosition) {
edgeMarker = new google.maps.Marker({
position: pixelLatLng,
map: map,
});
} else {
edgeMarker.setPosition(pixelLatLng);
}
var radius = google.maps.geometry.spherical.computeDistanceBetween(marker.getPosition(), edgeMarker.getPosition());
document.getElementById('info').innerHTML = "radius = " + (radius).toFixed(2) + " meters";
}
updated fiddle
code snippet:
function computeRadius() {
if (!overlay) return;
var centerPixel = overlay.getProjection().fromLatLngToDivPixel(marker.getPosition());
var outerPoint = new google.maps.Point(centerPixel.x + 151, centerPixel.y);
var pixelLatLng = overlay.getProjection().fromDivPixelToLatLng(outerPoint);
if (!edgeMarker || !edgeMarker.setPosition) {
edgeMarker = new google.maps.Marker({
position: pixelLatLng,
map: map,
});
} else {
edgeMarker.setPosition(pixelLatLng);
}
var radius = google.maps.geometry.spherical.computeDistanceBetween(marker.getPosition(), edgeMarker.getPosition());
document.getElementById('info').innerHTML = "radius = " + (radius).toFixed(2) + " meters";
}
var marker;
var overlay;
var edgeMarker;
var map;
function initGoogleMap() {
console.info('initGoogleMap');
var latitude = 10.314241194743438;
var longitude = 123.90536092883599;
var zoom = 17;
var latlng = new google.maps.LatLng(latitude, longitude);
var map_options = {
center: latlng,
zoom: zoom,
draggable: true,
zoomControl: true,
};
map = new google.maps.Map(document.getElementById('map_canvas'), map_options);
marker = new google.maps.Marker({
position: new google.maps.LatLng(latitude, longitude),
map: map,
icon: {
path: google.maps.SymbolPath.CIRCLE,
fillOpacity: 0.5,
fillColor: "#333",
strokeOpacity: 1.0,
strokeColor: '#CB0909',
strokeWeight: 0,
scale: 151 // in pixels
}
});
overlay = new google.maps.OverlayView();
overlay.draw = function() {};
overlay.setMap(map);
google.maps.event.addListenerOnce(map, 'idle', computeRadius);
google.maps.event.addListener(map, 'center_changed', computeRadius);
google.maps.event.addListener(map, 'zoom_changed', computeRadius);
console.info('init zoom level: ', zoom);
marker.bindTo('position', map, 'center');
}
google.maps.event.addDomListener(window, 'load', initGoogleMap);
/* Google Map */
#map_canvas {
border: 1px solid #ccc;
margin-top: 5px;
width: 100%;
height: 400px;
}
<script src="https://maps.googleapis.com/maps/api/js?libraries=places,geometry"></script>
<div id="map_canvas"></div>
<div id="info"></div>

Google Maps - Identical values in all info windows [duplicate]

This question already has answers here:
Google Maps JS API v3 - Simple Multiple Marker Example
(15 answers)
Closed 8 years ago.
Like many other people I'm finding identical values within my info windows. Alas, I've been using other posts in an attempt to troubleshoot. No luck.
Issue: Each of my infowindows shows the same values. Sigh.
Any help would be appreciated.
var map;
function initialize() {
var markers = [];
var mapOptions = {
zoom: 4,
scrollwheel: false,
streetViewControl: true,
panControl: true,
zoomControl: true,
zoomControlOptions: {
style: google.maps.ZoomControlStyle.LARGE
// position: google.maps.ControlPosition.LEFT_CENTER
},
center: new google.maps.LatLng(-25.898854, 134.091377)
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
setMarkers(map, beaches);
infowindow = new google.maps.InfoWindow({
content: "Loading..."
});
var input = /** #type {HTMLInputElement} */(
document.getElementById('pac-input'));
map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);
var searchBox = new google.maps.places.SearchBox(
/** #type {HTMLInputElement} */(input));
google.maps.event.addListener(searchBox, 'places_changed', function() {
var places = searchBox.getPlaces();
for (var i = 0, marker; marker = markers[i]; i++) {
marker.setMap(null);
}
markers = [];
var bounds = new google.maps.LatLngBounds();
for (var i = 0, place; place = places[i]; i++) {
var image = {
//url: 'assets/img/icon_pin.png',
//size: new google.maps.Size(40, 52),
//origin: new google.maps.Point(0, 0),
//anchor: new google.maps.Point(26, 20)
};
var marker = new google.maps.Marker({
map: map,
icon: image,
title: place.name,
position: place.geometry.location
});
markers.push(marker);
bounds.extend(place.geometry.location);
}
map.fitBounds(bounds);
});
google.maps.event.addListener(map, 'bounds_changed', function() {
var bounds = map.getBounds();
searchBox.setBounds(bounds);
});
}
var beaches = [
['Auburn', -33.847113, 151.04485, 1, '100', 'Parramatta', 'Road', 'Auburn', 'NSW', '2144', '02 7837 9800', '06:00 - 22:00', '06:00 - 22:00'],
['Balgowlah Platinum', -33.79284, 151.26376, 2, 'Shop 67, 197-215', 'Condamine', 'Street', 'Balgowlah', 'NSW', '2093', '1300 55 77 99', '06:00 - 21:30', '06:00 - 21:30'],
['Bankstown', -33.931208, 151.02895, 3, 'Unit 1-2, 9', 'Chapel', 'Street', 'South Bankstown', 'NSW', '2200', '02 8707 4700', '06:00 - 22:00', '06:00 - 22:00']
['Bayside', -37.954768, 145.03128, 4, '241 - 245', 'Bay', 'Road', 'Highett', 'VIC', '3190', '03 9559 7400', '06:00 - 22:00', '06:00 - 22:00']
];
function setMarkers(map, locations) {
var image = {
url: 'assets/img/icon_pin.png',
size: new google.maps.Size(40, 52),
origin: new google.maps.Point(0,0),
anchor: new google.maps.Point(26, 20)
};
var shape = {
coord: [1, 1, 1, 52, 40, 52, 40 , 1],
type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: image,
shape: shape
});
var contentString = '<div class="siteNotice"><h4>'+beach[0]+'</h4><p>'+beach[4]+' '+beach[5]+' '+beach[6]+' '+beach[7]+', '+beach[8]+', '+beach[9]+'</p><p><strong>Contact:</strong> '+beach[10]+'</p><p><strong>Opening Hours:</strong><br><span>Monday:</span> '+beach[11]+'<br><span>Tuesday:</span> '+beach[11]+'<br><span>Wednesday:</span> '+beach[11]+'<br><span>Thursday</span>: '+beach[11]+'<br><span>Friday:</span> '+beach[11]+'<br><span>Saturday</span>: '+beach[11]+'<br><span>Sunday:</span> '+beach[11]+'</p></div>';
google.maps.event.addListener(marker, "click", function () {
infowindow.setContent(contentString);
infowindow.open(map, this);
});
}
}
google.maps.event.addDomListener(window, 'load', initialize);
I had to create an array of info markers to hold the data.
var markers = [];
function addMapLocation(map, lat, long, title, message) {
var locationLatLong = new google.maps.LatLng(lat, long);
var locationMarker = new google.maps.Marker({ position: locationLatLong, map: map, title: title.trim() });
attachMessage(locationMarker, message);
markers.push(locationMarker);
}
function attachMessage(marker, message) {
var locationInfo = new google.maps.InfoWindow({ content: message });
google.maps.event.addListener(marker, 'click', function () { locationInfo.open(marker.get('map'), marker); });
}

api google maps V3 show title

I use this code on my site.
It show map with markers and when you tap on marker you go to another page.
And you see title when you put cursor on marker, i need that title always been shown.
<script src="http://maps.google.com/maps/api/js?sensor=false" type="text/javascript"></script>
<script type="text/javascript">
var points = [
["Page 1", 55.771683, 37.571274, 1, 'link to page 1'],
["Page 2", 55.7636, 37.606, 1, 'link to page 1']
];
function setMarkers(map, locations) {
var shape = {
coord: [1, 1, 1, 20, 18, 20, 18 , 1],
type: 'poly'
};
for (var i = 0; i < locations.length; i++) {
var flag = new google.maps.MarkerImage(
'http://googlemaps.googlermania.com/google_maps_api_v3/en/Google_Maps_Marker.png',
new google.maps.Size(37, 34),
new google.maps.Point(0,0),
new google.maps.Point(0, 19)
);
var place = locations[i];
var myLatLng = new google.maps.LatLng(place[1], place[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
icon: flag,
shape: shape,
title: place[0],
zIndex: place[3],
url: place[4]
});
google.maps.event.addListener(marker, 'click', function() {
// alert('go to ' + this.url); //
window.location.href = this.url;
});
}
}
function initialize() {
var myOptions = {
center: new google.maps.LatLng(55.766731,37.6010157,14),
zoom: 13,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
setMarkers(map, points);
}
</script>
<script type="text/javascript">
google.maps.event.addDomListener(window, 'load', initialize);
</script>
My question is i need that title -> (title: place[0]) allways show.
Now, when i use my code i see title just when i move cursor on marker.

Infobox doesn't show up in Google Maps

I'm trying to display data on a marker on Google Maps using Infoboxes from my database (using API v3). The fact is with Infowindows it worked perfectly but I want to style them and that's the reason I've switched to Infobox. But they don't show up as I expected like Infowindows.
ViewMap.php
<script type="text/javascript" src="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/src/infobox.js"></script>
<script type="text/javascript">
var infowindow;
var map;
var infobox;
function initialize() {
var myLatlng = new google.maps.LatLng(6.796396,79.877823);
var myOptions = {
zoom: 13,
center: myLatlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map-canvas"), myOptions);
var transitLayer = new google.maps.TransitLayer();
transitLayer.setMap(map);
downloadUrl("generateXml.php", function(data) {
data = xmlParse(data);
var markers = data.documentElement.getElementsByTagName("marker");
var bounds = new google.maps.LatLngBounds();
for (var i = 0; i < markers.length; i++) {
var latlng = new google.maps.LatLng(parseFloat(markers[i].getAttribute("lat")),
parseFloat(markers[i].getAttribute("lng")));
bounds.extend(latlng);
var marker = createMarker(markers[i].getAttribute("nom"),markers[i].getAttribute("descripcio"), latlng);
}
map.fitBounds(bounds);
});
}
function createMarker(nom,descripcio,latlng) {
var marker = new google.maps.Marker({
title:nom,
position: latlng,
map: map
});
infobox = new InfoBox({
content: descripcio,
disableAutoPan: false,
maxWidth: 150,
pixelOffset: new google.maps.Size(-140, 0),
zIndex: null,
boxStyle: {
background: "url('http://google-maps-utility-library-v3.googlecode.com/svn/trunk/infobox/examples/tipbox.gif') no-repeat",
opacity: 0.75,
width: "280px"
},
closeBoxMargin: "12px 4px 2px 2px",
closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif",
infoBoxClearance: new google.maps.Size(1, 1)
});
google.maps.event.addListener(marker, 'click', function() {
infobox.open(map, marker);
map.panTo(latlng);
});
return marker;
}
function downloadUrl(url, callback) {
var request = window.ActiveXObject ?
new ActiveXObject('Microsoft.XMLHTTP') :
new XMLHttpRequest;
request.onreadystatechange = function() {
if (request.readyState == 4) {
request.onreadystatechange = doNothing;
callback(request, request.status);
}
};
request.open('GET', url, true);
request.send(null);
}
function doNothing() {}
</script>
See this example page from google. I've used this as a template and it works great. https://developers.google.com/maps/articles/phpsqlajax_v3
InfoBox requires the maps-API, you must load the maps-API before infobox.js
Additionally:
You are using the same InfoBox for each marker(stored in the global infobox-variable, this variable will be overwritten on each call of createMarker, so the last marker will define the InfoBox used for each marker).
The descripcio-attribute of the last created marker is empty, that's why the infoboxes don't have any content.
Solution: add the var-keyword to make the infobox private:
var infobox = new InfoBox({/*options*/})

different markers on google maps v3

How can I add different markers to google map v3?
Here is example for my marker:
var latlng = new google.maps.LatLng(lat,lng);
var image = "../img/hotel_icon.png";
var locationDescription = this.locationDescription;
var marker = new google.maps.Marker({
map: map,
position: latlng,
title:'pk:'+name,
icon: image
});
bounds.extend(latlng);
setMarkes(map, marker, name, locationDescription);
});//close each
map.fitBounds(bounds);
});//close getjson
}//close initialize
function setMarkes(map, marker, name, locationDescription){
google.maps.event.addListener(marker, 'mouseover', function() {
infowindow.close();
infowindow.setContent('<h3>'+name+'</h3><em>'+locationDescription+'</em>');
infowindow.open(map, marker);
});
}
Here is one example that may help:
http://www.geocodezip.com/v3_markers_normal_colored_infowindows.html
code snippet:
function initialize() {
var myOptions = {
zoom: 10,
center: new google.maps.LatLng(-33.9, 151.2),
mapTypeControl: true,
mapTypeControlOptions: {
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
},
navigationControl: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
var map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
google.maps.event.addListener(map, 'click', function() {
infowindow.close();
});
setMarkers(map, beaches);
}
var icons = new Array();
icons["red"] = new google.maps.MarkerImage("http://www.geocodezip.com/mapIcons/marker_red.png",
// This marker is 20 pixels wide by 34 pixels tall.
new google.maps.Size(20, 34),
// The origin for this image is 0,0.
new google.maps.Point(0, 0),
// The anchor for this image is at 9,34.
new google.maps.Point(9, 34));
function getMarkerImage(iconColor) {
if ((typeof(iconColor) == "undefined") || (iconColor == null)) {
iconColor = "red";
}
if (!icons[iconColor]) {
icons[iconColor] = new google.maps.MarkerImage("http://www.geocodezip.com/mapIcons/marker_" + iconColor + ".png",
// This marker is 20 pixels wide by 34 pixels tall.
new google.maps.Size(20, 34),
// The origin for this image is 0,0.
new google.maps.Point(0, 0),
// The anchor for this image is at 6,20.
new google.maps.Point(9, 34));
}
return icons[iconColor];
}
// Marker sizes are expressed as a Size of X,Y
// where the origin of the image (0,0) is located
// in the top left of the image.
// Origins, anchor positions and coordinates of the marker
// increase in the X direction to the right and in
// the Y direction down.
var iconImage = new google.maps.MarkerImage('http://www.geocodezip.com/mapIcons/marker_red.png',
// This marker is 20 pixels wide by 34 pixels tall.
new google.maps.Size(20, 34),
// The origin for this image is 0,0.
new google.maps.Point(0, 0),
// The anchor for this image is at 9,34.
new google.maps.Point(9, 34));
var iconShadow = new google.maps.MarkerImage('http://www.google.com/mapfiles/shadow50.png',
// The shadow image is larger in the horizontal dimension
// while the position and offset are the same as for the main image.
new google.maps.Size(37, 34),
new google.maps.Point(0, 0),
new google.maps.Point(9, 34));
// Shapes define the clickable region of the icon.
// The type defines an HTML <area> element 'poly' which
// traces out a polygon as a series of X,Y points. The final
// coordinate closes the poly by connecting to the first
// coordinate.
var iconShape = {
coord: [9, 0, 6, 1, 4, 2, 2, 4, 0, 8, 0, 12, 1, 14, 2, 16, 5, 19, 7, 23, 8, 26, 9, 30, 9, 34, 11, 34, 11, 30, 12, 26, 13, 24, 14, 21, 16, 18, 18, 16, 20, 12, 20, 8, 18, 4, 16, 2, 15, 1, 13, 0],
type: 'poly'
};
var infowindow = new google.maps.InfoWindow({
size: new google.maps.Size(150, 50)
});
function createMarker(map, latlng, label, html, color) {
var contentString = '<b>' + label + '</b><br>' + html;
var marker = new google.maps.Marker({
position: latlng,
map: map,
shadow: iconShadow,
icon: getMarkerImage(color),
shape: iconShape,
title: label,
zIndex: Math.round(latlng.lat() * -100000) << 5
});
google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map, marker);
});
}
/**
* Data for the markers consisting of a name, a LatLng and a zIndex for
* the order in which these markers should display on top of each
* other.
*/
var beaches = [
['Bondi Beach', -33.890542, 151.274856, "red"],
['Coogee Beach', -33.923036, 151.259052, "blue"],
['Cronulla Beach', -34.028249, 151.157507, "green"],
['Manly Beach', -33.80010128657071, 151.28747820854187, "yellow"],
['Maroubra Beach', -33.950198, 151.259302, "orange"]
];
function setMarkers(map, locations) {
// Add markers to the map
for (var i = 0; i < locations.length; i++) {
var beach = locations[i];
var myLatLng = new google.maps.LatLng(beach[1], beach[2]);
var marker = createMarker(map, myLatLng, beach[0], beach[0], beach[3]);
}
}
google.maps.event.addDomListener(window, 'load', initialize);
html,
body {
height: 100%;
height: 100%;
padding: 0;
margin: 0
}
#map_canvas {
width: 100%;
height: 100%;
}
<div id="map_canvas"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCkUOdZ5y7hMm0yrcCQoCvLwzdM6M8s5qk"></script>
i have resolved a problem was easy just i have put this
var currentplace = $("#currentplace").text();
if(name == currentplace ){image = "../img/hotel_icon.png";}else{ image = "../img/home_icon.png";}