javascript - Can't add marker on google maps -


i've tried many ways , still couldn't add marker google map.

to understand, have @ following code below:

var marker;     var mycenter = new google.maps.latlng(55.1231231,-1.123131);      function initialize()     {     var mapoption = {       center: mycenter,       zoom:15,       maptypeid:google.maps.maptypeid.roadmap,       pancontrol: true,         pancontroloptions: {             position: google.maps.controlposition.right_top         },       };      var map = new google.maps.map(document.getelementbyid("googlemap"),mapoption);      var customcontroldiv = document.createelement('div');         customcontroldiv.id="customcontroldiv";         addcustomcontrol(customcontroldiv, map);         map.controls[google.maps.controlposition.top_center].push(customcontroldiv);     }      function placemarker(location) {       var marker = new google.maps.marker({         position: mylatlng,         map: map,         title:"you here!"       });     }      // add marker map     marker.setmap(map);      google.maps.event.adddomlistener(window, 'load', initialize); 

and html here

<div id="googlemap"></div> 

and didn't forget call google apis. , here

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"> </script> 

so, i've followed instructions on google maps here. still doesn't work. idea? thanks.

issues:

  • your map local initialize function
  • your placemarker function broken (you pass in location, use undefined mylatlng position).
  • you never call placemarker function
  • addcustomcontrol not defined

jsfiddle

    var marker;     var mycenter = new google.maps.latlng(55.1231231,-1.123131);      function initialize()     {       var mapoption = {         center: mycenter,         zoom:15,         maptypeid:google.maps.maptypeid.roadmap,         pancontrol: true,           pancontroloptions: {             position: google.maps.controlposition.right_top           },         };        var map = new google.maps.map(document.getelementbyid("googlemap"),mapoption);        // add marker map       var marker = new google.maps.marker({         position: mycenter,         map: map,         title:"you here!"       });      }      google.maps.event.adddomlistener(window, 'load', initialize); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -