var map
function detectBrowser() {
var useragent = navigator.userAgent;
var mapdiv = document.getElementById("map_canvas");
if (useragent.indexOf('iPhone') != -1 || useragent.indexOf('Android') != -1 ) {
mapdiv.style.width = '100%';
mapdiv.style.height = '100%';
} else {
mapdiv.style.width = '600px';
mapdiv.style.height = '800px';
}
}
function carregarMapa() {
lat=document.getElementById("txtLat").value;
lng=document.getElementById("txtLng").value;
var myLatlng = new google.maps.LatLng(lat,lng);
var mapOptions = {
zoom: 16,
center: myLatlng,
disableDefaultUI : false
}
var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);
map.setOptions({styles: [
{
featureType: "poi",
stylers: [
{ visibility: "off" }
]
}
]});
}
function criaPonto(){
plat=document.getElementById("txtLat").value;
plng=document.getElementById("txtLng").value;
var myLatlng = new google.maps.LatLng(plat,plng);
var marker2 = new google.maps.Marker({
position: myLatlng,
map: map,
title: 'Título Restaurante Y'});
}
google.maps.event.addDomListener(window, 'load', initialize);
Hello, I created this code in javascript trying to create a google map where I can load markers, so far, I only managed to create markers if I reset the map, and the idea was to create these markers at runtime.
For example:
I would create a marker if it was X away from the point my sensor located, otherwise that marker is not displayed.
The issue has been resolved! Thanks for the help from the user: link That was very present and managed to explain my mistakes.
Thanks!