-2

I've just hosted a simple website using Google Map API:

https://instructional-crime.000webhostapp.com/index.php

enter image description here

Basically it analyzes tweet information:

  • The map on the left shows the places that we're interested in
  • The pie chart in the middle shows the number of positive,negative and neutral tweets of the corresponding places (the calculation of sentiment is done using the VADER library, to be honest I just plugged the sentences in without knowing anything about the library like a code monkey :(, since this is just practice)
  • The world map on the right shows where the tweets about the selected location come from.
  • The table below shows the tweets and the sentiment score

The problem is with the world map. Suppose I want to select a region where there are many tweets, when I select it I also need to highlight that region, but as you can see there are so many places with tweets, if I use markers there would be too many markers. So how do I make it so that when I click on a region with tweets (say, Washington DC), the selected region gets highlighted that distinguishes it from the rest?

geocodezip
  • 158,664
  • 13
  • 220
  • 245
Dang Manh Truong
  • 795
  • 2
  • 10
  • 35
  • @xomena No it is not, the question you referenced from is about searching for a place then highlights it, but this question is about clicking on a place then hightlights it. They are 2 different things – Dang Manh Truong Oct 01 '17 at 14:37
  • You should understand that there is no way to highlight region using API, you will need an external data. That why I marked as duplicated. – xomena Oct 01 '17 at 20:57
  • Wether is by searching or by clicking, unless you get the polygons of each administrative subdivision you want to highlight, google api won't provide them for you. – ffflabs Oct 01 '17 at 21:58

1 Answers1

0

You will have have to draw the polygons yourself after acquiring the latitude and longitude and change it to Google map object (google.maps.LatLng).

For example:

var statesobj = {"AK": [new google.maps.LatLng(70.0187, -141.0205),
new google.maps.LatLng(70.1292, -141.7291),
new google.maps.LatLng(70.4515, -144.8163)]}

You can also try to use geo charts http://code.google.com/apis/chart/interactive/docs/gallery/geochart.html

Allanckw
  • 641
  • 1
  • 6
  • 17