3
I am new to the development with this API and would like to show on the map that I am developing the current user position.
My code:
<script type="text/javascript" src="http://maps.googleapis.com/maps/api/js?key=AIzaSyB7s0zDs4RMWrpqWjAmr7OD-BQbq8LubZk&sensor=false"></script>
<script>
var geocoder;
var map;
var marker;
function initialize() {
var latlng = new google.maps.LatLng(-18.8800397, -47.05878999999999);
var options = {
zoom: 5,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("mapa"), options);
geocoder = new google.maps.Geocoder();
marker = new google.maps.Marker({
map: map,
draggable: true,
});
marker.setPosition(latlng);
}
$(document).ready(function () {
initialize();
});
I could not get my current location ,I tested it in my code and also tested it in Jsfiddle and also failed!!.
– Hans Miller
@Hansmiller You have to allow the site to get its location when requested.
– André Ribeiro
Pow sorry thanks! @Andre worked, how do I leave my map with the streets and streets of the place where I meet? why in the current form the map shows all Brazil. wanted that map that shows the streets. @Andre I am new in developing with this api vc can mi indicate sites ,video tutorials??
– Hans Miller
@Hansmiller Take a look here to see how to select a different map type. As for the tutorial, the guide to the documentation API is great and covers virtually everything you can do. Don’t forget to mark the answer as accepted if you are satisfied.
– André Ribeiro