Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to edit default marker in google maps
    primarykey
    data
    text
    <p>Kindly check this map view: <a href="http://gmaps-samples-v3.googlecode.com/svn/trunk/map_language/map_lang.html" rel="nofollow">http://gmaps-samples-v3.googlecode.com/svn/trunk/map_language/map_lang.html</a></p> <p>If you click on A or B, it will show location name in default marker. I wish to show some custom texts here. How can I do that? My JavaScript code for this is:</p> <pre><code>var directionsDisplay; var directionsService = new google.maps.DirectionsService(); var map; var oldDirections = []; var currentDirections = null; //getting latitude and longitude from address var latitude; var longitude; var geocoder = new google.maps.Geocoder(); var address = "Downtown Berkeley"; geocoder.geocode( { "address": address}, function(results, status) { if (status == google.maps.GeocoderStatus.OK) { // do something with the geocoded result // latitude = results[0].geometry.location.lat() longitude = results[0].geometry.location.lng() alert(latitude ) } }); //map initialize function initialize() { var myOptions = { zoom: 13, center: new google.maps.LatLng(-33.879,151.235), mapTypeId: google.maps.MapTypeId.ROADMAP } map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); //adding marker var marker = new google.maps.Marker ( { position: new google.maps.LatLng(latitude , longitude), map: map, title: "Click me" } ); var infowindow = new google.maps.InfoWindow({ content: "Location info:&lt;br/&gt;Country Name:&lt;br/&gt;LatLng:" }); google.maps.event.addListener(marker, "click", function () { // Calling the open method of the infoWindow infowindow.open(map, marker); }); directionsDisplay = new google.maps.DirectionsRenderer({ "map": map, "preserveViewport": true, "draggable": true }); directionsDisplay.setPanel(document.getElementById("directions_panel")); google.maps.event.addListener(directionsDisplay, "directions_changed", function() { if (currentDirections) { oldDirections.push(currentDirections); } currentDirections = directionsDisplay.getDirections(); }); calcRoute(); } function calcRoute() { var start = "El Cerrito del Norte"; var end = "Downtown Berkeley"; var request = { origin:start, destination:end, travelMode: google.maps.DirectionsTravelMode.DRIVING }; directionsService.route(request, function(response, status) { if (status == google.maps.DirectionsStatus.OK) { directionsDisplay.setDirections(response); } }); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload