Ik heb https://developers.google.com/maps/documentation gelezen /javascript/overlaysnu al een tijdje en ik krijg een aangepast pictogram voor mijn kaart niet werkend.
Hier is mijn javascript:
var simplerweb = new google.maps.LatLng(55.977046,-3.197118);
var marker;
var map;
function initialize() {
var myOpts = {
center: simplerweb,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(document.getElementById("map_canvas"), myOpts);
marker = new google.maps.Marker({
map: map,
draggable: true,
animation: google.maps.Animation.DROP,
position: simplerweb
});
google.maps.event.addListener(marker, 'click', toggleBounce);
}
function toggleBounce() {
if (marker.getAnimation() != null) {
marker.setAnimation(null);
} else {
marker.setAnimation(google.maps.Animation.BOUNCE);
}
}
Enige tips voor een complete beginner met gmaps?
Antwoord 1, autoriteit 100%
marker = new google.maps.Marker({
map:map,
// draggable:true,
// animation: google.maps.Animation.DROP,
position: new google.maps.LatLng(59.32522, 18.07002),
icon: 'http://cdn.com/my-custom-icon.png' // null = default icon
});
Antwoord 2, autoriteit 16%
Probeer
var marker = new google.maps.Marker({
position: map.getCenter(),
icon: 'http://imageshack.us/a/img826/9489/x1my.png',
map: map
});
van hier
https://developers.google.com/maps/ documentatie/javascript/voorbeelden/marker-symbol-custom
Antwoord 3, autoriteit 13%
Symbool dat u wilt op de gewenste kleur!
Ik was al dagen op zoek naar dit antwoord en hier is de juiste en gemakkelijke manier om een aangepaste markering te maken:
‘http://chart.googleapis. com/chart?chst=d_map_pin_letter&chld=xxx%7c5680FC%7c000000&.png‘ waarbij xxx de tekst is en 5680fc de hexadecimale kleurcode van de achtergrond en 000000 de hexadecimale kleurcode van de tekst is.
Deze markeringen zijn volledig dynamisch en u kunt elk ballonpictogram maken dat u maar wilt. Verander gewoon de URL.
Antwoord 4
LatLng hello = new LatLng(X, Y); // whereX & Y are coordinates
Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
R.drawable.university); // where university is the icon name that is used as a marker.
mMap.addMarker(new MarkerOptions().icon(BitmapDescriptorFactory.fromBitmap(icon)).position(hello).title("Hello World!"));
mMap.moveCamera(CameraUpdateFactory.newLatLng(hello));