> For the complete documentation index, see [llms.txt](https://javascriptuse.gitbook.io/javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://javascriptuse.gitbook.io/javascript/xay-dung-popup-lay-vi-tri-map-ap-dung-pointfinder-ok.md).

# Xây dựng popup lấy vị trí map áp dụng pointfinder (ok)

![](/files/-MLp_0XWrqIbEOC6jp8t)

C:\xampp\htdocs\test\wp-content\themes\pointfinder\footer.php

```
<div id="pfwidgetmaps"></div>
```

C:\xampp\htdocs\test\wp-content\plugins\pointfindercoreelements\public\js\theme-map-functions.js

```
jQuery(document).ready(function($) {
  function pointfinderbuildmap_ct(handler) {
    var $mapobject = $('#' + handler + '');
    var we_special_key = 0;
    var we_lat = 0;
    var we_lng = 0;
    var we_zoom = 12;
    var we_maxzoom = 18;
    console.log(we_lat);
    console.log('tesssssssssssssssss1');
    /* OSM */
    var tiles = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
      maxZoom: parseInt(we_maxzoom),
      attribution: '&copy; <a href="https://osm.org/copyright">OpenStreetMap</a> contributors'
    });
    /* Create Map */
    var mapelement = L.map('' + handler + '', {
      zoomControl: false,
      center: [we_lat, we_lng],
      zoom: 14,
      layers: [tiles],
      gestureHandling: true
    });
    mapelement.dragging.enable();
    mapelement.scrollWheelZoom.enable();
    L.control.zoom({
      position: 'topleft'
    }).addTo(mapelement);
    $.pointfinderlocationmark = new L.Control.PFDMapLocate({
      position: 'topleft',
      setView: 'once',
      strings: {
        title: 'Locate me!',
        metersUnit: "km",
        feetUnit: "mile",
        popup: 'You are here!'
      },
      metric: true,
      icon: "fas fa-map-marker-alt",
      iconLoading: 'fas fa-spinner fa-spin',
      drawCircle: false,
      showPopup: true,
      returnToPrevBounds: false,
      keepCurrentZoomLevel: false,
      locateOptions: {
        maxZoom: 12,
        enableHighAccuracy: true
      },
      followCircleStyle: {
        radius: 10000
      }
    }).addTo(mapelement);
    return mapelement;
  }
  function pfgeolocation_findme_ct(we_geoc_type) {
    var pointfinderbuildmap_ctv = pointfinderbuildmap_ct('pfwidgetmaps');
    pointfinderbuildmap_ctv.off('locationfound');
    pointfinderbuildmap_ctv.locate({
      watch: false,
      setView: false,
      enableHighAccuracy: true,
      custom: 'geobutton'
    }).on('locationfound', function(e) {
      console.log("lionelpham1");
      $.pointfindersetbounds(e.latlng.lat, e.latlng.lng);
      pointfinderbuildmap_ctv.stopLocate();
      $.ajax({
        url: theme_scriptspf.ajaxurl,
        type: 'GET',
        dataType: 'json',
        data: {
          action: "pfget_geocoding",
          security: theme_scriptspf.pfget_geocoding,
          lat: "" + e.latlng.lat + "",
          lng: "" + e.latlng.lng + "",
          option: 'reverse',
          ctype: "" + we_geoc_type + ""
        },
      }).complete(function() {
        console.log('data');
      });
    }).on('locationerror', function(e) {
      console.log(e);
      alert(e.message);
    });
  }
  pfgeolocation_findme_ct('photon');
});
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://javascriptuse.gitbook.io/javascript/xay-dung-popup-lay-vi-tri-map-ap-dung-pointfinder-ok.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
