Ver Mensaje Individual
  #1 (permalink)  
Antiguo 17/12/2017, 11:21
dairo65
 
Fecha de Ingreso: abril-2011
Mensajes: 168
Antigüedad: 13 años
Puntos: 5
donde pongo el codigo siguiente

saludos y gracias por apoyar al novato
les comento tengo un codigo en js el cual es de mapbox y tuengo la localizacion y todo



Código Javascript:
Ver original
  1. var map = new mapboxgl.Map({
  2.     container: 'map',
  3.     style: 'mapbox://styles/mapbox/streets-v9',
  4.     center: [-73.58, 3.70],
  5.     zoom: 5
  6. });
  7.  
  8. document.getElementById('btnGuardar').onclick =  function(e){
  9.     guardarLocalizacion();
  10. };
  11.  
  12. // Adicionando controles de zoom y rotación
  13. map.addControl(new mapboxgl.NavigationControl());
  14.  
  15. var localizador = new mapboxgl.GeolocateControl({
  16.     positionOptions: {
  17.         enableHighAccuracy: false
  18.     },
  19.     trackUserLocation: false,
  20.     showUserLocation: false
  21. });
  22.  
  23. map.addControl(localizador); //Adicionar control localizador
  24.  
  25. var geojson;
  26.  
  27. //Evento que se activa al momento de activar la localización
  28. localizador.on('geolocate', function(e) {
  29.     var lat = e.coords.latitude;
  30.     var lng = e.coords.longitude;
  31.  
  32.     geojson = {
  33.         type: 'FeatureCollection',
  34.         features: [
  35.         {
  36.             type: 'Feature',
  37.             geometry: {
  38.                 type: 'Point',
  39.                 coordinates: [lng, lat]
  40.             }
  41.         }]
  42.     };
  43.  
  44.     document.getElementById('lat').textContent  = lat;
  45.     document.getElementById('lng').textContent  = lng;
  46.  
  47.    
  48.  
  49.         map.addLayer({
  50.             "id": "punto",
  51.             "type": "symbol",
  52.             "source": {
  53.                 "type": "geojson",
  54.                 "data": {
  55.                     type: 'FeatureCollection',
  56.                     features: [
  57.                     {
  58.                         type: 'Feature',
  59.                         geometry: {
  60.                             type: 'Point',
  61.                             coordinates: [lng, lat]
  62.                         }
  63.                     }]
  64.                 }
  65.             },
  66.             "layout": {
  67.                 "icon-image": "local",
  68.                 "icon-size": 0.25
  69.             }
  70.         });
  71.  
  72.     });


y quisiera poner un mensaje que esta en este codigo;
Código Javascript:
Ver original
  1. #marker {
  2.     background-image: url('/mapbox-gl-js/assets/washington-monument.jpg');
  3.     background-size: cover;
  4.     width: 50px;
  5.     height: 50px;
  6.     border-radius: 50%;
  7.     cursor: pointer;
  8. }
  9.  
  10. .mapboxgl-popup {
  11.     max-width: 200px;
  12. }
  13.  
  14.  
  15.  
  16. var monument = [-77.0353, 38.8895];
  17. var map = new mapboxgl.Map({
  18.     container: 'map',
  19.     style: 'mapbox://styles/mapbox/light-v9',
  20.     center: monument,
  21.     zoom: 15
  22. });
  23.  
  24. // create the popup
  25. var popup = new mapboxgl.Popup()
  26.     .setText('Construction on the Washington Monument began in 1848.');
  27.  
  28. // create DOM element for the marker
  29. var el = document.createElement('div');
  30. el.id = 'marker';
  31.  
  32. // create the marker
  33. new mapboxgl.Marker(el)
  34.     .setLngLat(monument)
  35.     .setPopup(popup) // sets a popup on this marker
  36.     .addTo(map);

pero no se en que parte del codigo lo ubico ya que si lo pongo al final me da error
alguna idea?

muchas gracias ya que en js soy muy novato