javascript - google map not showing up my location -
i show location on google map, don't know wrong. not showing thing :
<div id="map-canvas" style="width:100%; height:300px;"> </div> . . . <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script> // google map if ($('#map-canvas').length) { var google_map_lat = 40.7564971, google_map_lng = -73.9743277; var map, service; jquery(function($) { $(document).ready(function() { var latlng = new google.maps.latlng(google_map_lat, google_map_lng); var myoptions = { zoom: 14, center: latlng, maptypeid: google.maps.maptypeid.roadmap }; map = new google.maps.map(document.getelementbyid("map-canvas"), myoptions); var marker = new google.maps.marker({ position: latlng, map: map }); marker.setmap(map); $('a[href="#google-map-tab"]').on('shown.bs.tab', function(e) { google.maps.event.trigger(map, 'resize'); map.setcenter(latlng); }); }); }); } </script> </body>
updated
my console messages :
using //@ indicate sourcemappingurl pragmas deprecated. use //# instead jquery.js:1:0 password fields present on insecure (http://) page. security risk allows user login credentials stolen.[learn more] <unknown> syntaxerror: expected expression, got '<' myjs.js:1:0 typeerror: $(...).position(...) undefined custom.js:308:20 use of getpreventdefault() deprecated. use defaultprevented instead.
i think need include jquery library, because using $(document).ready(function() . have updated code adding jquery library. please try below code , hope work.
<div id="map-canvas" style="width:100%; height:300px;"> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script> <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script> <script> // google map if ($('#map-canvas').length) { var google_map_lat = 40.7564971, google_map_lng = -73.9743277; var map, service; jquery(function($) { $(document).ready(function() { var latlng = new google.maps.latlng(google_map_lat, google_map_lng); var myoptions = { zoom: 14, center: latlng, maptypeid: google.maps.maptypeid.roadmap }; map = new google.maps.map(document.getelementbyid("map-canvas"), myoptions); var marker = new google.maps.marker({ position: latlng, map: map }); marker.setmap(map); $('a[href="#google-map-tab"]').on('shown.bs.tab', function(e) { google.maps.event.trigger(map, 'resize'); map.setcenter(latlng); }); }); }); } </script>
Comments
Post a Comment