Cant Add Markers To Custom Tile Map
I'm new to coding for Google Maps. Ive been trying to make myself a map using custom image tiles (Out of World of Warcraft) and i've been following a guide here: http://facepunch.c
Solution 1:
See the documentation on adding Markers, to add the marker to the map, use the 'map' property
var marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
title: "Hello World!"
});
code snippet:
functioninitialize() {
var mapOptions = {
minZoom: 2,
maxZoom: 7,
isPng: true,
mapTypeControl: false,
streetViewControl: false,
center: new google.maps.LatLng(0, 0),
zoom: 3,
mapTypeControlOptions: {
mapTypeIds: ['custom', google.maps.MapTypeId.ROADMAP],
style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
}
};
map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
map.mapTypes.set('custom', CustomMapType);
map.setMapTypeId('custom');
// To add the marker to the map, use the 'map' propertyvar marker = new google.maps.Marker({
position: map.getCenter(),
map: map,
title: "Hello World!"
});
}
google.maps.event.addDomListener(window, 'load', initialize);
functionCustomMapType() {}
CustomMapType.prototype.tileSize = new google.maps.Size(256, 256);
CustomMapType.prototype.maxZoom = 7;
CustomMapType.prototype.getTile = function(coord, zoom, ownerDocument) {
var div = ownerDocument.createElement('DIV');
var baseURL = 'http://d1m6g5gl70bc4l.cloudfront.net/';
baseURL += zoom + '_' + coord.x + '_' + coord.y + '.png';
div.style.width = this.tileSize.width + 'px';
div.style.height = this.tileSize.height + 'px';
div.style.backgroundColor = '#1B2D33';
div.style.backgroundImage = 'url(' + baseURL + ')';
return div;
};
CustomMapType.prototype.name = "Custom";
CustomMapType.prototype.alt = "Tile Coordinate Map Type";
var map;
varCustomMapType = newCustomMapType();
html {
height: 100%
}
body {
height: 100%;
margin: 0px;
padding: 0px
}
#map_canvas {
height: 100%;
z-index: 0;
}
#gmnoprint {
width: auto;
}
<scripttype="text/javascript"src="http://maps.googleapis.com/maps/api/js"></script><divid="map_canvas"style="background: #1B2D33;"></div>
Post a Comment for "Cant Add Markers To Custom Tile Map"