javascript - adding an InfoBox google map -


i'm trying incorporate info box google map: have following code

function initializeswansea() {    var latlng = new google.maps.latlng(51.656591, -3.902619);      var styles = [                     {                         featuretype: 'landscape.natural',                         elementtype: 'all',                         stylers: [                             { hue: '#ffffff' },                             { saturation: -100 },                             { lightness: 100 },                             { visibility: 'on' }                         ]                     },{                         featuretype: 'water',                         elementtype: 'geometry',                         stylers: [                             { hue: '#93ddf6' },                             { saturation: 72 },                             { lightness: 4 },                             { visibility: 'simplified' }                         ]                     },{                         featuretype: 'landscape.man_made',                         elementtype: 'all',                         stylers: [                             { hue: '#ffffff' },                             { saturation: -100 },                             { lightness: 100 },                             { visibility: 'simplified' }                         ]                     },{                         featuretype: 'road',                         elementtype: 'all',                         stylers: [                             { hue: '#999999' },                             { saturation: -100 },                             { lightness: -6 },                             { visibility: 'simplified' }                         ]                     },{                         featuretype: 'poi',                         elementtype: 'labels',                         stylers: [                             { hue: '#a7a9ac' },                             { saturation: -93 },                             { lightness: -15 },                             { visibility: 'simplified' }                         ]                     },{                         featuretype: 'poi',                         elementtype: 'geometry',                         stylers: [                             { hue: '#80c342' },                             { saturation: 15 },                             { lightness: -34 },                             { visibility: 'on' }                         ]                     },{                         featuretype: 'administrative.country',                         elementtype: 'labels',                         stylers: [                             { hue: '#0054a6' },                             { saturation: 100 },                             { lightness: -36 },                             { visibility: 'on' }                         ]                     },{                         featuretype: 'road.highway',                         elementtype: 'labels',                         stylers: [                             { hue: '#999999' },                             { saturation: -100 },                             { lightness: -6 },                             { visibility: 'on' }                         ]                     }                 ];      var mapoptions = {         zoom: 15,         center: latlng,         maptypeid: 'styled',         maptypecontrol: false,         streetviewcontrol: false,         zoomcontrol: true,         scalecontrol: true,         maptypecontroloptions: {             maptypeids: [ 'styled']           }     };      var boxtext = document.createelement("div");     boxtext.style.csstext = "border: 1px solid black; margin-top: 8px; background: yellow; padding: 5px;";     boxtext.innerhtml = "city hall, sechelt<br>british columbia<br>canada";      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     };      var ib = new infobox(myoptions);      var map = new google.maps.map(document.getelementbyid("map-swansea"), mapoptions);       var swansea = new google.maps.marker({         position: new google.maps.latlng(51.651532, -3.913906),         map: map,         title: "swansea"     });       var styledmaptype = new google.maps.styledmaptype(styles, { name: 'styled' }); map.maptypes.set('styled', styledmaptype);      $(window).resize( function() { map.setcenter(latlng) }); }  $(function() {     initializeswansea(); }); 

i want label content, address details etc appear when map loads. have read link still unsure how incorporate code? can help?

the code ok. need show infobox :

google.maps.event.addlistener(swansea, 'click', function() {    ib.open(map, swansea); }); 

see code in fiddle -> http://jsfiddle.net/escex/ (with other minor changes)


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -