Note that there are some explanatory texts on larger screens.

plurals
  1. POAdd markers & show route to Google Maps v3 in Jquery mobile
    primarykey
    data
    text
    <p>I am developing a mobile website with jQuery Mobile. At this moment the geolocation works. When the GPS is activated the app zooms to my location, but my location is not marked with a marker.</p> <p>Also i can't get another marker on the map on another location. What i am trying to realize is:</p> <p>show my location on the map with a marker, show another location on the map based on lat.ing, Show the route between the to markers.</p> <p>The code that works with geolocation is below:</p> <pre><code>&lt;script type="text/javascript"&gt; var initialLocation; var uscenter = new google.maps.LatLng(51.539821,5.995593); var browserSupportFlag = new Boolean(); var map; var markersArray = []; var infowindow = new google.maps.InfoWindow(); var contentString = []; var markerJustClicked = 0; var current_bodyWidth = 0; // function initialize() { $('.page-trailsearch-map').live("pageshow", function() { var map_height = window.innerHeight - 42; var map_div = document.getElementById("map-trailsearch-canvas"); map_div.style.height = map_height + 'px'; InitializeMap(); current_bodyWidth = document.body.clientWidth; $(window).bind("resize", function() { if (current_bodyWidth != document.body.clientWidth) { var map_height = window.innerHeight - 42; var map_div = document.getElementById("map-trailsearch-canvas"); map_div.style.height = map_height + 'px'; current_bodyWidth = document.body.clientWidth; } }); }); function InitializeMap() { var myOptions = { mapTypeId: google.maps.MapTypeId.ROADMAP, mapTypeControlOptions: { mapTypeIds: [ google.maps.MapTypeId.ROADMAP, google.maps.MapTypeId.SATELLITE, google.maps.MapTypeId.HYBRID, google.maps.MapTypeId.TERRAIN ] } } map = new google.maps.Map(document.getElementById("map-trailsearch-canvas"), myOptions); // Try W3C Geolocation method (Preferred) if(navigator.geolocation) { browserSupportFlag = true; navigator.geolocation.getCurrentPosition(function(position) { initialLocation = new google.maps.LatLng(position.coords.latitude,position.coords.longitude); map.setCenter(initialLocation); map.setZoom(15); }, function() { handleNoGeolocation(browserSupportFlag); }, {enableHighAccuracy:true}); } else { // Browser doesn't support Geolocation browserSupportFlag = false; handleNoGeolocation(browserSupportFlag); } // Update markers if info window closes google.maps.event.addListener(infowindow, 'closeclick', function() { markerJustClicked = 0; updateMarkers(); }); } function handleNoGeolocation(errorFlag) { if (errorFlag == true) { initialLocation = uscenter; contentString = "Uw locatie kan niet vastgesteld worden. &lt;br&gt; Activeer GPS en probeer opnieuw."; } else { initialLocation = uscenter; contentString = "Uw locatie kan niet vastgesteld worden, omdat dit niet wordt ondersteund door uw browser."; } map.setCenter(initialLocation); map.setZoom(13); infowindow.setContent(contentString); infowindow.setPosition(initialLocation); infowindow.open(map); } &lt;/script&gt; &lt;div data-role="content"&gt; &lt;div id="map-trailsearch-canvas"&gt;&lt;/div&gt; &lt;/div&gt; </code></pre> <p>And this is the code i got from the sample codes on the offical google maps v3 site: I have edited it but i didn't get a marker, let alone the route.</p> <pre><code>$('#map_canvas').gmap().bind('init', function(evt, map) { $('#map_canvas').gmap('addMarker', { /*id:'m_1',*/ 'position': '42.345573,-71.098326', 'bounds': true } ); }); </code></pre> <p>Many Thanks all.</p> <p>Maxcim</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload