Find the latitude and longitude of a given IP address using IPMapper

I get the following error: "RefrenceError: IPMApper not defined" when I try to get the Latitude and longitude for a given IP address using IPMapper. I refine the code for your clarity.

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>IP Address geocoding on Google Maps</title> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="ipmapper.js"></script> $(function(){ try{ IPMapper.initializeMap("map"); IPMapper.addIPMarker("111.111.111.111"); } catch(e){ alert(e); } }); </head> <body> <input id="ip" name="ip" type="text" /> <button onclick="IPMapper.addIPMarker($('#ip').val());">Geocode</button> <div id="map" style="height: 500px;border: red 4px;"></div> </body> </html> 
-3
source share
2 answers

Do you have an ipmapper.js file in your solution / project? Does the src link match the location on your server?

Try using the IPMapperjs link to use the absolute path in the project, not the relative path

(the file will be at the root of the site)

+1
source

You have to include these three js

 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <script type="text/javascript" src="ipmapper.js"></script> 

Please refer to this link.

0
source

Source: https://habr.com/ru/post/944298/


All Articles