c# - displaying markers on a google map in javascript -


i javascript beginner , trying create markers on google map. first of getting gps co-ordinates database splitting apart lattitude , longlitude values, adding them 2 separate listboxes called lstboxlatgps , lstboxlonggps in c#

foreach (string item in gpslatlist)     {         lstboxlatgps.items.add(item);     } foreach (string item in gpslonglist)     {         lstboxlonggps.items.add(item);     } 

now in javascript want take items in listboxes , create markers on map have 2 functions:

        function getlatvalues()          {             var arrvalues= new array();             var listbox = document.getelementbyid("<%=lstboxlatgps.clientid%>");             (var = 0; < listbox.options.length; i++)              {arrvalues[i]= listbox.options[i].text }             return (arrvalues);         }         function getlongvalues()          {             var arrvalues= new array();             var listbox = document.getelementbyid("%=lstboxlonggps.clientid%>");             (var = 0; < listbox.options.length; i++)              {arrvalues[i]= listbox.options[i].text }             return (arrvalues);         } 

then add arrays made markers:

        function initialize()         {             var mapcanvas = document.getelementbyid('map-canvas');             var mapoptions =             {                 center: new google.maps.latlng(-28.4792811, 24.6722268),                 zoom: 6,                 maptypeid: google.maps.maptypeid.roadmap             }             var map = new google.maps.map(mapcanvas, mapoptions);             map.set('styles', [   {       "featuretype": "landscape",       "stylers": [         { "color": "#c9d7bb" }       ]   }, {       "featuretype": "administrative.province",       "elementtype": "labels.text",       "stylers": [         { "visibility": "on" },         { "color": "#ffc23d" }       ]   }, {       "featuretype": "poi.attraction",       "stylers": [         { "visibility": "on" },         { "color": "#9be586" }       ]   }, {       "featuretype": "administrative.province",       "elementtype": "geometry",       "stylers": [         { "visibility": "on" },         { "color": "#000000" },         { "weight": 3.2 }       ]   }             ]);              var gpslatarray = new array();             var gpslongarray = new array();             gpslatarray = getlatvalues();             gpslongarray = getlongvalues();              (var = 0; < gpslatarray.length; i++)             {                 var marker = new google.maps.marker({position: gpslatarray[i],gpslongarray[i] });                 marker.setmap(map);             }         }         google.maps.event.adddomlistener(window, 'load', initialize); 

when map supposed displayed, blank, not showing map @ all.

you need add div in aspx page display map.

<div class="img-thumbnail" id="map-canvas" style="width: 369px; height: 289px;"></div> 

Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -