I read points from the database as JSON to create map markers and an unstructured list on the page. After adding some code to configure list items, the map stopped displaying marker icons at the first request - until a page reload was issued. Is it because of the time from the API? Can a list object be built from an array after loading the map, or is there some other way to speed up the code that can fix the problem? Markers with double the number of markers (300+) are loaded on the map, so I know that the problem is adding formatting to the list object. No clustering required. A demo page is available here.
Signed by JS n00b. Thank you ...... JSON POWERED GOOGLEMAP
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script> <script type="text/javascript" charset="utf-8"> var map; var infoWindow = new google.maps.InfoWindow(); function initialize() { var myLatlng = new google.maps.LatLng(49.57154029531499,-125.74951171875); var myOptions = { zoom: 8, center: myLatlng, mapTypeId: google.maps.MapTypeId.TERRAIN, streetViewControl: false } this.map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } <!-- load points from database into Locations JSON --> $(document).ready(function () { initialize(); $.getJSON("map-service.php?action=listpoints", function(json) { if (json.Locations.length > 0) { for (i=0; i<json.Locations.length; i++) { var location = json.Locations[i]; addMarker(location); } } }); </script> </head> <body> <div id="banner" {vertical-align:text-top;} > <img src="test.jpg" alt="Logo" style="width:150px;height:150px;vertical-align:middle"> <img src="test.png" alt="Logo" style="vertical-align:middle"> </div> <div id="map_canvas" > Map Here! </div> <div id="mindthegap"></div> <div id="list" > </div> </body>
source share